package com.msk.common.wechatV3.config;

import com.msk.common.utils.StringUtils;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import java.security.cert.X509Certificate;
import java.util.Date;

/**
 * 微信支付服务端参数
 * @author admin
 */
@Configuration
@ConfigurationProperties(prefix = "wxpayconfigv3")
public class WxPayV3Config {

	/**
	 * 商户号
	 */
	private String mchId;

	/**
	 * appID
	 */
	private String appId;

	/**
	 * 密钥key
	 */
	private String apiKey;
	/**
	 * 应用私钥
	 */
	private String wxPayPrivateKey;

	/**
	 * 应用公钥
	 */
	private String wxPayPublicKey;

	/**
	 * 证书序列号
	 */
	private String serialNumber;

	/**
	 * X509Certificate JSON序列化
	 */
	private String cert;

	/**
	 * 证书
	 */
	private X509Certificate certificate;

	/**
	 * 证书过期时间
	 */
	private Date expireTime;

	/**
	 * 生效时间
	 */
	private Date effectiveTime;

	/**
	 * 回调基础URL
	 */
	private String baseUrl;

	/**
	 * 云账户secretId
	 */
	private String secretId;

	/**
	 * 云账户secretKey
	 */
	private String secretKey;

	/**
	 * 策略的具体编号
	 */
	private String bizType;

	/**
	 * 小程序appId
	 */
	private String miniAppId;

	/**
	 * 小程序秘钥
	 */
	private String miniSecretKey;

	/**
	 * 小程序登录接口地址
	 */
	private String miniLoginUrl;

	/**
	 * 小程序获取访问凭证接口地址
	 */
	private String miniAccessTokenUrl;

	/**
	 * 小程序获取手机号接口地址
	 */
	private String miniPhoneNumberUrl;

	public String getMchId() {
		return mchId;
	}

	public void setMchId(String mchId) {
		this.mchId = mchId;
	}

	public String getAppId() {
		return appId;
	}

	public void setAppId(String appId) {
		this.appId = appId;
	}

	public String getApiKey() {
		return apiKey;
	}

	public void setApiKey(String apiKey) {
		this.apiKey = apiKey;
	}

	public String getBaseUrl() {
		return baseUrl;
	}

	public void setBaseUrl(String baseUrl) {
		this.baseUrl = baseUrl;
	}

	public String getSecretId() {
		if (StringUtils.isEmpty(secretId)) {
			secretId = "";
		}
		return secretId;
	}

	public void setSecretId(String secretId) {
		this.secretId = secretId;
	}

	public String getSecretKey() {
		if (StringUtils.isEmpty(secretKey)) {
			secretKey = "";
		}
		return secretKey;
	}

	public void setSecretKey(String secretKey) {
		this.secretKey = secretKey;
	}

	public String getBizType() {
		if (StringUtils.isEmpty(bizType)) {
			bizType = "JBBWMZY_001";
		}
		return bizType;
	}

	public void setBizType(String bizType) {
		this.bizType = bizType;
	}

	public String getMiniAppId() {
		if (StringUtils.isEmpty(miniAppId)) {
			miniAppId = "wx92fa30f038d1e23e";
		}
		return miniAppId;
	}

	public void setMiniAppId(String miniAppId) {
		this.miniAppId = miniAppId;
	}

	public String getMiniSecretKey() {
		if (StringUtils.isEmpty(miniSecretKey)) {
			miniSecretKey = "2dd317f488f75be160d716d441e9c01d";
		}
		return miniSecretKey;
	}

	public void setMiniSecretKey(String miniSecretKey) {
		this.miniSecretKey = miniSecretKey;
	}

	public String getMiniLoginUrl() {
		if (StringUtils.isEmpty(miniLoginUrl)) {
			miniLoginUrl = "https://api.weixin.qq.com/sns/jscode2session";
		}
		return miniLoginUrl;
	}

	public void setMiniLoginUrl(String miniLoginUrl) {
		this.miniLoginUrl = miniLoginUrl;
	}

	public String getMiniAccessTokenUrl() {
		if (StringUtils.isEmpty(miniAccessTokenUrl)) {
			miniAccessTokenUrl = "https://api.weixin.qq.com/cgi-bin/token";
		}
		return miniAccessTokenUrl;
	}

	public void setMiniAccessTokenUrl(String miniAccessTokenUrl) {
		this.miniAccessTokenUrl = miniAccessTokenUrl;
	}

	public String getMiniPhoneNumberUrl() {
		if (StringUtils.isEmpty(miniPhoneNumberUrl)) {
			miniPhoneNumberUrl = "https://api.weixin.qq.com/wxa/business/getuserphonenumber";
		}
		return miniPhoneNumberUrl;
	}

	public void setMiniPhoneNumberUrl(String miniPhoneNumberUrl) {
		this.miniPhoneNumberUrl = miniPhoneNumberUrl;
	}

	public String getWxPayPrivateKey() {
		return wxPayPrivateKey;
	}

	public void setWxPayPrivateKey(String wxPayPrivateKey) {
		this.wxPayPrivateKey = wxPayPrivateKey;
	}

	public String getWxPayPublicKey() {
		return wxPayPublicKey;
	}

	public void setWxPayPublicKey(String wxPayPublicKey) {
		this.wxPayPublicKey = wxPayPublicKey;
	}

	public String getSerialNumber() {
		return serialNumber;
	}

	public void setSerialNumber(String serialNumber) {
		this.serialNumber = serialNumber;
	}

	public String getCert() {
		return cert;
	}

	public void setCert(String cert) {
		this.cert = cert;
	}

	public X509Certificate getCertificate() {
		return certificate;
	}

	public void setCertificate(X509Certificate certificate) {
		this.certificate = certificate;
	}

	public Date getExpireTime() {
		return expireTime;
	}

	public void setExpireTime(Date expireTime) {
		this.expireTime = expireTime;
	}

	public Date getEffectiveTime() {
		return effectiveTime;
	}

	public void setEffectiveTime(Date effectiveTime) {
		this.effectiveTime = effectiveTime;
	}
}
